home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-25 | 4.2 KB | 133 lines | [TEXT/PJMM] |
- { Tools Plus Tutorial - - Pop-Up Menus }
-
- { NOTE: }
- { The MWERKS compiler directived ($IFC MWERKS) indicates code that is compiled only by }
- { the CodeWarrior compiler. THINK Pascal and Metrowerks CodeWarrior Pascal have }
- { _slight_ differences, and this compiler directive lets you use one source for both compilers. }
- { You can remove the code that does not pertain to your compiler. }
-
-
- program Tutorial;
- uses
- {$IFC MWERKS}
- Dialogs, Fonts, Processes, SegLoad, TextEdit, ToolsPlus, Windows;
- {$ELSEC}
- ToolsPlus;
- {$ENDC}
-
-
- const
- { Pop-up menu constants for more readable code… }
- ordinaryPopUp = 1;
- popDownMenu = 2;
- littlePopUp = 3;
-
- DoneButton = 255;
-
-
- var
- Poll: TPPollRecord; {Polling record to retrieve event information}
- ExitTheDemo: boolean; {Should the demo terminate?}
-
- theButton: integer; {Button number clicked in an alert }
-
-
-
-
-
- { - - - - - - - - - - - - - - - - - - - - - - - - - - - }
- procedure ApplicationInitialization;
- const
- DemoWindow1 = 1;
- begin
- { Do all the application setup before you start polling for events… }
-
- WindowOpen(DemoWindow1, 0, 0, 225, 170, '', dBoxProc + wCenter, noGoAway, Modal);
-
-
- { Create a Pop-Up Menu that hides the 'down arrow'.}
- { The pop-up menu is populated with icons. Note that the Menu Manager adds 256 to the icon specifier }
- { (the number following the '^' mark). Example: ^44 + 256 = 300, or 'cicn' resource ID 300 is used. }
- NewPopUp(ordinaryPopUp, 100, 20, 206, 20, 'Search Here:', popupIconTitle + popupNoArrow, enabled);
- PopUpMenu(ordinaryPopUp, 1, enabled, 'Desktop^44');
- PopUpMenu(ordinaryPopUp, 2, enabled, 'Hard Disk^45');
- PopUpMenu(ordinaryPopUp, 3, enabled, 'Tools Plus^46');
- PopUpMenu(ordinaryPopUp, 4, enabled, 'THINK C^47');
- PopUpMenu(ordinaryPopUp, 5, enabled, 'Libraries^47');
- PopUpMenu(ordinaryPopUp, 6, enabled, '#Includes^47');
- CheckPopUp(ordinaryPopUp, 1, on); {Select first item by placing a check mark beside it}
-
-
- { Create a 'pull-down' menu with a fixed title inside the control…}
- NewPopUp(popDownMenu, 100, 50, 206, 50, 'Format', popupFixedTitle, enabled);
- PopUpMenu(popDownMenu, 1, enabled, 'Clear');
- PopUpMenu(popDownMenu, 2, enabled, 'Paragraph…');
- PopUpMenu(popDownMenu, 3, enabled, 'Character…');
- PopUpMenu(popDownMenu, 4, enabled, 'Style…');
-
-
- { Create a pop-up menu using Geneva 9pt…}
- TextFont(Geneva);
- TextSize(9);
- NewPopUp(littlePopUp, 100, 80, 133, 80, 'Size:', popupUseWFont + popupNoArrow, enabled);
- PopUpMenu(littlePopUp, 1, enabled, '9');
- PopUpMenu(littlePopUp, 2, enabled, '10');
- PopUpMenu(littlePopUp, 3, enabled, '12!•'); { This item is selected by being marked with a bulled (•) }
- PopUpMenu(littlePopUp, 4, enabled, '14');
- PopUpMenu(littlePopUp, 5, enabled, '18');
- PopUpMenu(littlePopUp, 6, enabled, '24');
- PopUpMenu(littlePopUp, 7, enabled, '36');
-
-
- NewButton(DoneButton, 85, 130, 140, 150, 'Done', pushButProc + DefaultButton, enabled, notSelected);
- ExitTheDemo := false;
- end;
-
-
- { - - - - - - - - - - - - - - - - - - - - - - - - - - - }
- begin
- {$IFC MWERKS}
- {Toolbox initialization - - Done automatically by THINK Pascal}
- InitGraf(@qd.thePort);
- InitFonts;
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(nil);
- MaxApplZone;
- {$ENDC}
-
- if not InitToolsPlus(0, 1, UseColor) then
- ExitToShell;
-
- ApplicationInitialization;
-
- while not ExitTheDemo do {Main Event Loop}
- if PollSystem(Poll) then {If an event is available, process the event…}
-
- case Poll.What of
-
- doButton: {User clicked a button ('Done' is the only button we have)… }
- ExitTheDemo := true;
-
- doPopUpMenu:
- case Poll.Menu.Num of
- ordinaryPopUp:
- { Put check mark (√) beside selected item. Previously selected item is }
- { automatically deselected (this feature is optional).}
- CheckPopUp(Poll.Menu.Num, Poll.Menu.Item, on);
-
- popDownMenu:
- { Your app would likely execute a process here… }
- theButton := AlertBox(noteIcon, 'Your application would do something now.', -OkAlert);
-
- littlePopUp:
- { Put bullet (•) beside selected item. Previously selected item is }
- { automatically deselected (this feature is optional).}
- PopUpMark(Poll.Menu.Num, Poll.Menu.Item, DotChar);
- end;
-
-
- otherwise {All other events are ignored}
- end
- end.